<!DOCTYPE html>
<html>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width,initial-scale=1.0'>
    <meta http-equiv='X-UA-Compatible' content='ie=edge'>
    <title>Document</title>
</head>

<body>
    <div id='app'>
        <!-- 1. 给要操作的DOM元素设置ref属性 -->
        <input type="text" ref="xxx">
		<p>{{msg}}</p>
    </div>
    <script src='./vue.js'></script>
    <script>
        new Vue({
            el: '#app',
            data(){
				return{
					msg: 'abc'
				}
            },
            // 2. 在选项mounted方法中获取要操作的DOM元素
            // mounted(){}方法在Vue渲染完页面后会自动触发
            // 类比之前的window.onload
            mounted() {
				
                console.log(this.$refs.xxx);
                this.$refs.xxx.focus();
            },
            methods: {
            }
        });
    </script>
</body>

</html>